<?php
#注册插件
RegisterPlugin("Yun_level","ActivePlugin_Yun_level");

function ActivePlugin_Yun_level() {
	global $zbp;
		//添加 插件所用样式及JS
	$zbp->header .='<link rel="stylesheet" href="'.$zbp->host.'zb_users/plugin/Yun_level/Yun_level.css" type="text/css" media="all"/>';
	// $zbp->header .='<style type="text/css">'. "\r\n";
	// $zbp->header .='.Yun_level-lv{color: ' . $zbp->Config('Yun_level')->lv_color . '}'. "\r\n";
	// $zbp->header .='Yun_level-nc{color: ' . $zbp->Config('Yun_level')->nc_color . '}'. "\r\n";
	// $zbp->header .='</style>'. "\r\n";
}
function InstallPlugin_Yun_level() {
	if (!function_exists('AppCentre_VerifyV2')) {
	  $zbpUrl = $zbp->host . 'zb_users/plugin/AppCentre/main.php?id=231';
	  $zbp->ShowError("您的应用中心版本过低，<a href=\"$zbpUrl\" target=\"_blank\">请点击这里更新应用中心插件</a>");
	}
	$verify = AppCentre_VerifyV2('2188', 'theme'); // plugin代表插件，theme代表主题
	if ($verify !== '0ff8f6581a8d8ad0feae7ebf2c59e0ea') {
	  $zbp->ShowError($verify);
	}
	global $zbp;
	//配置初始化
	if (!$zbp->Config('Yun_level')->HasKey('version')) {
		$zbp->Config('Yun_level')->version = '1.0';
		$zbp->Config('Yun_level')->lv_color	=	'#ffb800';
		$zbp->Config('Yun_level')->nc_color	=	'#1E9FFF';
		$zbp->SaveConfig('Yun_level');
	}
}
//评论等级
function Yun_level_author_class($comment_author_email){
    global $zbp;
    $comment=$zbp->table['Comment'];
	$adminEmail =$zbp->Config('Yun_level')->glyadmin;
	$author_count ='SELECT comm_Name,COUNT(*) AS alluser FROM '.$comment.' WHERE comm_Email ="'.$comment_author_email.'"';
	$array=$zbp->db->Query($author_count);
	$array=current($array);
	$author_count=GetValueInArray($array,'alluser');
	if($comment_author_email ==$adminEmail){
		 echo '<span class="Yun_level-mark Yun_level-lv" style="background-color:#dd3333;">'.$zbp->Config('Yun_level')->glych.'</span>';
	}else{
	if($author_count>=1 && $author_count< 10){
		echo ' <span class="Yun_level-mark Yun_level-lv" title="经验：'.$author_count.'">Lv.1</span><span class="Yun_level-mark Yun_level-nc">'.$zbp->Config('Yun_level')->pldjch1.'</span>';}
	else if($author_count>=10 && $author_count< 20){
		echo ' <span class="Yun_level-mark Yun_level-lv" title="经验：'.$author_count.'">Lv.2</span><span class="Yun_level-mark Yun_level-nc">'.$zbp->Config('Yun_level')->pldjch2.'</span>';}
	else if($author_count>=20 && $author_count< 40){
		echo ' <span class="Yun_level-mark Yun_level-lv" title="经验：'.$author_count.'">Lv.3</span><span class="Yun_level-mark Yun_level-nc">'.$zbp->Config('Yun_level')->pldjch3.'</span>';}
	else if($author_count>=40 && $author_count< 80){
		echo ' <span class="Yun_level-mark Yun_level-lv" title="经验：'.$author_count.'">Lv.4</span><span class="Yun_level-mark Yun_level-nc">'.$zbp->Config('Yun_level')->pldjch4.'</span>';}
	else if($author_count>=80 && $author_count< 160){
		echo ' <span class="Yun_level-mark Yun_level-lv" title="经验：'.$author_count.'">Lv.5</span><span class="Yun_level-mark Yun_level-nc">'.$zbp->Config('Yun_level')->pldjch5.'</span>';}			
	else if($author_count>=160 &&$author_count< 320){
		echo ' <span class="Yun_level-mark Yun_level-lv" title="经验：'.$author_count.'">Lv.6</span><span class="Yun_level-mark Yun_level-nc">'.$zbp->Config('Yun_level')->pldjch6.'</span>';}
	else if($author_count>=320 && $author_count< 640){
		echo ' <span class="Yun_level-mark Yun_level-lv" title="经验：'.$author_count.'">Lv.7</span><span class="Yun_level-mark Yun_level-nc">'.$zbp->Config('Yun_level')->pldjch7.'</span>';}
	else if($author_count>=640 && $author_count< 1280){
		echo ' <span class="Yun_level-mark Yun_level-lv" title="经验：'.$author_count.'">Lv.8</span><span class="Yun_level-mark Yun_level-nc">'.$zbp->Config('Yun_level')->pldjch8.'</span>';}
	else if($author_count>= 1280){
		echo ' <span class="Yun_level-mark Yun_level-lv" title="经验：'.$author_count.'">Lv.9</span><span class="Yun_level-mark Yun_level-nc">'.$zbp->Config('Yun_level')->pldjch9.'</span>';}
	}
}
function UninstallPlugin_Yun_level() {}